package org.ctstudio.oa.duty.config;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import javax.sql.DataSource;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

@Configuration
@EnableTransactionManagement
@ComponentScan(basePackages = { "org.ctstudio.oa.duty.service", "org.ctstudio.oa.duty.dao" })
public class ContextConfig {

  @Bean
  public ExecutorService getThreadPool() {
    return Executors.newSingleThreadExecutor();
  }

  @Bean
  public DataSourceTransactionManager dataSourceTransactionManager(DataSource datasource) {
    return new DataSourceTransactionManager(datasource);
  }
}